package com.zeng.sboot.amqp.producer.controller;

import com.zeng.sboot.amqp.producer.config.amqp.EmailSmsSender;
import com.zeng.sboot.amqp.producer.config.amqp.OrderSender;
import com.zeng.sboot.demo.amqp.domain.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/order")
public class OrderController {

    @Autowired
    private OrderSender orderSender;
    @Autowired
    private EmailSmsSender emailSmsSender;

    @RequestMapping(value = "/s1")
    public String sendOrder() {
        for(int i = 0; i< 5 ;i++) {
            Order order = new Order(1l + i, "商品：good-" + (i + 1), "item-" + (i + 1));
            orderSender.OrderSender1(order);
        }
        //Order order = new Order(1l, "商品：good-1", "item-1");
        //String result = orderSender.OrderSender1(order);
        return "success";
    }

    @RequestMapping(value = "/s2")
    public void testEmailSmsSender() {
        emailSmsSender.sender();
    }
}
